/*     */ package com.qmsk.business.store.goodsStockdtl.controller;
/*     */ 
/*     */ import com.qmsk.business.store.goodsStockdtl.dao.GoodsStockDtlDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.IOException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/goodsStockDtl"})
/*     */ public class GoodsStockDtlController
/*     */ {
/*  35 */   private static final Logger logger = Logger.getLogger(GoodsStockDtlController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GoodsStockDtlDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  55 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try
/*     */     {
/*  58 */       Map params = new HashMap();
/*     */ 
/*  60 */       MapUtils.addToMap(params, "gId", 
/*  61 */         RequestUtils.getLong(request, "gId"));
/*  62 */       MapUtils.addToMap(params, "hId", 
/*  63 */         RequestUtils.getLong(request, "hId"));
/*  64 */       MapUtils.addToMap(params, "rId", 
/*  65 */         RequestUtils.getLong(request, "rId"));
/*  66 */       MapUtils.addToMap(params, "batch", 
/*  67 */         RequestUtils.getString(request, "batch"));
/*  68 */       MapUtils.addToMap(params, "count", 
/*  69 */         RequestUtils.getInt(request, "count"));
/*  70 */       MapUtils.addToMap(params, "mDate", 
/*  71 */         RequestUtils.getDate(request, "mDate"));
/*  72 */       MapUtils.addToMap(params, "vDay", 
/*  73 */         RequestUtils.getInt(request, "vDay"));
/*     */ 
/*  75 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  76 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     }
/*     */     catch (Exception e) {
/*  79 */       logger.error(e);
/*     */ 
/*  81 */       ResponseUtils.setErrorMsgResponse(
/*  82 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*     */     throws IOException
/*     */   {
/*     */     try
/*     */     {
/* 102 */       int nResult = 0;
/* 103 */       String sData = RequestUtils.getStringOfData(request);
/* 104 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 106 */       if (p != null) {
/* 107 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 109 */       if (nResult > 0)
/* 110 */         DbConnection.commit();
/*     */       else {
/* 112 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 115 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 116 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 117 */         response);
/*     */     } catch (Exception e) {
/* 119 */       DbConnection.rollback();
/* 120 */       logger.error(e);
/* 121 */       ResponseUtils.setErrorMsgResponse(
/* 122 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 123 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 137 */     String sJson = RequestUtils.getStringOfId(request);
/*     */     try {
/* 139 */       int nResult = this.dao.deleteList(sJson);
/* 140 */       if (nResult > 0)
/* 141 */         DbConnection.commit();
/*     */       else {
/* 143 */         DbConnection.rollback();
/*     */       }
/* 145 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 146 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 147 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 150 */       DbConnection.rollback();
/* 151 */       logger.error(e);
/* 152 */       ResponseUtils.setErrorMsgResponse(
/* 153 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 154 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*     */   {
/*     */     try
/*     */     {
/* 173 */       int nResult = 0;
/* 174 */       String sData = RequestUtils.getStringOfData(request);
/* 175 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 177 */       nResult = this.dao.applyUpdates(p);
/* 178 */       if (nResult > 0)
/* 179 */         DbConnection.commit();
/*     */       else {
/* 181 */         DbConnection.rollback();
/*     */       }
/* 183 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 184 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 185 */         response);
/*     */     } catch (Exception e) {
/* 187 */       logger.error(e);
/* 188 */       DbConnection.rollback();
/* 189 */       ResponseUtils.setErrorMsgResponse(
/* 190 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 191 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.goodsStockdtl.controller.GoodsStockDtlController
 * JD-Core Version:    0.5.3
 */